package cn.itsource.pethome.basic.util;

import cn.itsource.pethome.basic.service.IVerificationCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 发送验证码
 */
@RestController
@RequestMapping("/code")
public class VerificationCode {
    /**
     * 验证码
     */
    @Autowired
    private IVerificationCodeService verificationCodeService;

    /**
     * 注册获取验证码
     * @param param
     * @return
     */
    @PostMapping("/verificationcode")
    public AjaxResult sendPhoneCode(@RequestBody Map<String,String> param){
        //获取手机号
        String phone = param.get("phone");
        //获取验证码
        return verificationCodeService.sendPhoneCode(phone);
    }
    /**
     * 登录获取验证码
     * @param param
     * @return
     */
    @PostMapping("/verificationPhoneCode")
    public AjaxResult sendLoginPhoneCode(@RequestBody Map<String,String> param){
        //获取手机号
        String phone = param.get("phone");
        //获取验证码
        return verificationCodeService.sendLoginPhoneCode(phone);
    }
}
